(*
  Copyright (c) 2009 Barry Schwartz

  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation
  files (the "Software"), to deal in the Software without
  restriction, including without limitation the rights to use,
  copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following
  conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  OTHER DEALINGS IN THE SOFTWARE.
*)

open XNum
open UTypes
open Substitute
open GlyphMetric
open FontMetric
open Box
  
type builder_interface = {
  add_char : uc_char -> unit;
  add_break : (num -> bool ->
                 ((box, box) char_item) list ->
                   ((box, box) char_item) list ->
                     ((box, box) char_item) list -> unit);
  add_kern : num -> num -> unit;
  add_box : box -> unit;
  add_cmd : box -> unit;
  set_font : font_metric -> glyph_composer -> unit;
  set_hyphen_params : JustHyph.hyphen_params -> unit
}

type 'a builder = (builder_interface * (unit -> 'a))

val add_char : builder_interface -> uc_char -> unit
  
val add_break :
  builder_interface ->
  num ->
  bool ->
  ((box, box) char_item) list ->
  ((box, box) char_item) list -> ((box, box) char_item) list -> unit
  
val add_kern : builder_interface -> num -> num -> unit
val add_box : builder_interface -> box -> unit
val add_cmd : builder_interface -> box -> unit
val set_font : builder_interface -> font_metric -> glyph_composer -> unit
val set_hyphen_params : builder_interface -> JustHyph.hyphen_params -> unit
val add_char_list : builder_interface -> uc_char list -> unit
val add_box_list : builder_interface -> box list -> unit
val add_cmd_list : builder_interface -> box list -> unit
val void_builder : builder_interface
val simple_builder : font_metric -> glyph_composer -> (box list) builder
